package cn.ihuizi.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.ihuizi.dao.impl.AdminDaoImpl;
import cn.ihuizi.entity.Admin;
import cn.ihuizi.service.AdminService;
import cn.ihuizi.service.impl.AdminServiceImpl;
import cn.ihuizi.util.Admin_Id;

/**
 * Servlet implementation class AdminUpdateSelServlet
 */
@WebServlet("/AdminUpdateSelServlet")
public class AdminUpdateSelServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		/*response.getWriter().append("Served at: ").append(request.getContextPath());*/
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=UTF-8");
		String name = request.getParameter("name");
		name=new String(name.getBytes("ISO-8859-1"),"utf-8");
		String phone = request.getParameter("phone");
		String email = request.getParameter("email");
		String account = Admin_Id.account;
		AdminService adminService = new AdminServiceImpl();
		boolean b = adminService.updateAdminSel(new Admin(name,account,phone,email));
		if(b) {
			response.getWriter().write("恭喜您，修改信息成功！");
			System.out.println("成功1");
		}else {
			response.getWriter().write("修改信息失败！");
			System.out.println("失败1");
		}
	
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
